#include <stdio.h>
#include <string.h>

typedef struct Weapon
{
	char caName[32];
	float fWeight;
}Weapon;

void bubble(Weapon *w, int count)
{
	if (NULL == w || count <= 0)
	{
		return;
	}
	int i = 0;
	int j = 0;
	Weapon tmp;
	for (; i<count-1; i++)
	{
		for (j=0; j<count-1-i; j++)
		{
			if (w[j].fWeight < w[j+1].fWeight)
			{
				tmp = w[j];
				w[j] = w[j+1];
				w[j+1] = tmp;
			}
		}
	}
}

int main(void)
{
	Weapon w[3] = {{"九尺钉耙", 5048}
				   , {"禅杖", 3033}
				   , {"如意金箍棒", 13500}};

	bubble(w, 3);

	int i=0;
	for (; i<3; i++)
	{
		printf("name:%s, weight:%.1f\n"
			   , w[i].caName, w[i].fWeight);
	}

	return 0;
}
